<template>
	<view class="main">
		<u-navbar :is-back="true" title="选择商品" :background="background" back-icon-color="#000000" title-color="#000"
			title-bold="true">
		</u-navbar>

		<view class="serch">
			<u-search :clearabled="true" shape="square" bg-color="#fff" placeholder="输入搜索关键字" :show-action="false" v-model="keywords" @search="getshoplist">
			</u-search>
		</view>
		<view class="content">
			<view class="shop" v-for="(item,index) in shoplist" :key="index" @click="back(item)">
				<image :src="item.image" mode=""></image>
				<view class="shop_r">
					<view class="shop_tit">
						{{item.name}}
					</view>
					<view class="status">
						{{item.on_sale==1?'在售中':'已下架'}}
					</view>
					<view class="money">
						¥{{item.minPrice}}-{{item.maxPrice}}
					</view>
				</view>
			</view>
		</view>


	</view>
</template>
<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#fff'
				},
				shoplist: [],
				keywords:''
			}
		},
		onLoad(option) {
			this.getshoplist()

		},
		mounted() {

		},
		onShow() {
			console.log(this.id);
		},
		methods: {
			router(path) {
				uni.navigateTo({
					url: path
				})
			},
			getshoplist() {
				global.$http.request({
					url: '/shopapi/goods/goodList',
					data: {
						keywords:this.keywords,
						token: uni.getStorageSync('token')
					}
				}).then(res => {
					if (res.data.code == 200) {
						console.log(res.data.data);
						this.shoplist = res.data.data
					}
				})
			},
			back(details) {
			// #ifdef APP-NVUE
			const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
			// #endif
			// #ifndef APP-NVUE
			const eventChannel = this.getOpenerEventChannel();
			// #endif
			eventChannel.emit('selectType', details);
			uni.navigateBack({
				delta: 1,
			})
			},
		
		}
	}
</script>
<style lang="scss">
	page {
		font-family: PingFang SC;
		width: 750rpx;
		margin: 0 auto 180rpx auto;

		background-color: #f7f7f7;

		.main {
			width: 750rpx;
			margin: 0 auto;

			.serch {
				margin: 20rpx;
			}

			.content {

				.shop {
					background-color: #fff;
					padding: 25rpx;
					display: flex;
					margin-bottom: 10rpx;

					image {
						width: 180rpx;
						height: 180rpx;
					}

					.shop_r {
						padding-left: 26rpx;

						.shop_tit {
							font-size: 28rpx;
							font-weight: 400;
							color: #000000;
						}
					}

					.status {
						padding: 32rpx 0 17rpx 0;
						font-size: 24rpx;
						font-weight: 400;
						color: #FF0707;
					}

					.money {
						font-size: 24rpx;
						font-weight: 400;
						color: #010101;
					}
				}
			}
		}
	}
</style>
